# Maintainer: Galen Abell <galen@galenabell.com>
# Contributor: Galen Abell <galen@galenabell.com>
pkgname=packer
pkgver=1.6.1
pkgrel=0
pkgdesc="Build Automated Machine Images"
url="https://www.packer.io/"
arch="all !armhf !armv7 !mips !mips64"
license="MPL-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/hashicorp/packer/archive/v$pkgver.tar.gz"
builddir="$srcdir/src/github.com/hashicorp/$pkgname"

prepare() {
	mkdir -p ${builddir%/*}
	mv $srcdir/$pkgname-$pkgver "$builddir"/
	default_prepare
}

build() {
	GO111MODULE=off GOPATH="$srcdir" go build -v -o bin/$pkgname \
		-ldflags "-X main.GitCommit=v$pkgver -X github.com/hashicorp/packer/version.Prerelease= -s -w"
}

check() {
	GOPATH="$srcdir" go list -mod=vendor . | xargs -t -n4 go test -mod=vendor -timeout=2m -parallel=4
	bin/$pkgname -v
}

package() {
	install -Dm755 "$builddir"/bin/$pkgname "$pkgdir"/usr/bin/$pkgname
}

cleanup_srcdir() {
	go clean -modcache
	default_cleanup_srcdir
}

sha512sums="3b4b21eac425fec44a47a5799dcb5387099de06b777906a4b7c5bf169c71d8b82ab4296a21c8b60daefa4546d5a814b8d9f23e4d2afcf0eb91c3338d8f327ce7  packer-1.6.1.tar.gz"
